<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" href="../layui/css/layui.css">
	<title>编辑</title>
	<style>
	  	.layui-input{
		    display: block;
		    width: 70%;
		    padding-left: 10px;
	 	}
    </style>
</head>
<body>
<!-- 表单 -->
<blockquote class="layui-elem-quote">
编辑
</blockquote>
<form class="layui-form"  action="" method="post" lay-filter="userEdit" >
  <input type="hidden" name="id" id="id" value="${user.id}">
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-block">
      <input type="text" name="username" lay-verify="username" autocomplete="off"  value="${user.username}" placeholder="请输入账户名" class="layui-input">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="password" name="password" lay-verify="password" autocomplete="off" value="${user.password}"   placeholder="请输入密码" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
      <button type="button" class="layui-btn layui-btn-primary" id="cancelButton">取消</button>
    </div>
  </div>
</form>
<script src="../layui/layui.js"></script>
<script>
window.onload = function(){
	layui.use(['form','jquery' ], function(){
		 var form = layui.form
		 var $ = layui.jquery;
		  //监听取消
		  $("#cancelButton").click(function(){
			  closeIframe();
		  })
		  //关闭弹出层
		  function closeIframe(){
			  var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			  parent.layer.close(index)
		  }
		  //监听提交
		  form.on('submit(submit)', function(data){
			  $.ajax({
				  url:"/shopping/user/save",
				  type:"POST",
			  	  data:data.field,
			  	  success:function(result){
			  		  if(result==200){
			  			   parent.layer.msg("操作成功",{icon: 1,time:1000},function(){
			  			      closeIframe();
			  			   });
			  		  }else{
			  			   layer.msg("操作失败",{icon:2}); 
			  		  }
			  	   }
			    })
		  });
	});
}
</script>
</body>
</html>